import requests


def checkIDCardNum(idCardNum):
    idCardNum=str(idCardNum)
    if len(idCardNum)!=18:
        return False
    idCardNum =idCardNum.upper()
    newNum =idCardNum[0:17]
    sigma =0
    wi = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    codes = ['1','0','x','9','8','7','6','5','4','3','2']
    for index,value in enumerate(newNum):
        sigma += int(value) * wi[index]
    newNum += codes[sigma%11]
    return newNum == idCardNum


idcardNum=input("请输入要查询的身份证号码：")
if checkIDCardNum(idcardNum):
    url= "http://widget.cifuwu.com/idcard/" +str(idcardNum)
    result = requests.get(url)
    data =result.json()
    print("区域信息: " +data["data"]["areaInfo"]["detail"])
    print("年龄: "  + str(data["data"]["born"]["age"]))
    print("生日: "  + data["data"]["born"]["solar"]["birthday"])
    print("农历: "  + data["data"]["born"]["lunar"]["chinese_birthday"])
    print("生肖: " + data["data"]["born"]["lunar"]["chinese_zodiac"])
    print("星座: "  + data["data"]["born"]["solar"]["zodiac"])
    print("性别: "  + data["data"]["gender"]["cn"])
    # print(data)
    # print(type(data))
else:
    print('身份证号码不合法，请求新输入！')
#print(checkIDCardNum(360981199808054301))